package boot

import (
	"beesoft.ink/application/media/app/workflow"
	"beesoft.ink/application/media/app/workflow/activity"
	"go.temporal.io/sdk/client"
	"go.temporal.io/sdk/worker"
	"log"
)

func InitWorkflow() {
	options := client.Options{
		HostPort: "192.168.1.100:7233",
	}
	c, err := client.NewClient(options)
	if err != nil {
		log.Fatalln("Unable to create client", err)
	}
	defer c.Close()

	w := worker.New(c, "app-media-task-queue", worker.Options{})

	w.RegisterWorkflow(workflow.AudioSynthesisWorkflow)

	w.RegisterActivity(activity.AudioSynthesisSplitTextActivity)
	w.RegisterActivity(activity.AudioSynthesisGenerateStructuredDataActivity)
	w.RegisterActivity(activity.AudioSynthesisGroupDataActivity)
	w.RegisterActivity(activity.AudioSynthesisGenerateSsmlActivity)
	w.RegisterActivity(activity.AudioSynthesisAudioSynthesisActivity)
	w.RegisterActivity(activity.AudioSynthesisConcatenateAudioActivity)

	err = w.Start()
	if err != nil {
		log.Fatalln("Unable to start Worker", err)
	}
}
